/**
 * create by young (young2f@outlook.com) on 2020/10/1
 */
'use strict';
import React, {Component} from 'react';
import {Tag, Tooltip} from 'antd';
import styles from '../../index.less';

const _theme = require('../../../theme');
export default class MaterialElement extends Component {
  constructor(props) {
    super(props);

  }

  componentWillUnmount() {

  }

  getLevelColor(level) {
    switch (level) {
      case 0:
        return _theme['primary-color'];
      case 1:
        return _theme['primary-color-1'];
      case 2:
        return _theme['primary-color-2'];
      default:
        return _theme['primary-color'];
    }
  }

  /**
   *  <ul>
   <li>
   名称：{name}
   </li>
   <li>
   编码：{code}
   </li>
   </ul>
   * @returns {*}
   */
  render() {
    let {code, name, path, unit,subcategory,spec,type,number, level, color =this.getLevelColor(level)} = this.props;

    return (
      <tbody>
      {name && <tr>
        <th><Tag className={styles.tag} color={color}>名称</Tag></th>
        <Tooltip title={name}>
          <td className={styles.text}>{name}</td>
        </Tooltip>

      </tr>}

      {code && <tr>
        <th><Tag className={styles.tag} color={color}>编码</Tag></th>
        <Tooltip title={code}>
          <td>{code}</td>
        </Tooltip>
      </tr>}
      {subcategory && <tr>
        <th><Tag className={styles.tag} color={color}>小类</Tag></th>
        <Tooltip title={subcategory}>
          <td>{subcategory}</td>
        </Tooltip>
      </tr>}
      {spec && <tr>
        <th><Tag className={styles.tag} color={color}>规格</Tag></th>
        <Tooltip title={spec}>
          <td>{spec}</td>
        </Tooltip>
      </tr>}
      {type && <tr>
        <th><Tag className={styles.tag} color={color}>类型</Tag></th>
        <Tooltip title={type}>
          <td>{type}</td>
        </Tooltip>
      </tr>}
      {number && <tr>
        <th><Tag className={styles.tag} color={color}>编号</Tag></th>
        <Tooltip title={number}>
          <td>{number}</td>
        </Tooltip>
      </tr>}
      {unit && <tr>
        <th><Tag className={styles.tag} color={color}>单位</Tag></th>
        <Tooltip title={unit}>
          <td>{unit}</td>
        </Tooltip>
      </tr>}
      </tbody>
    );
  }
}
